package com.wzh.glsc.product.web;

import com.wzh.glsc.product.service.SkuInfoService;
import com.wzh.glsc.product.vo.SkuItemVo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import java.util.concurrent.ExecutionException;

/**
 * @author xiaoming
 * @PackageName:com.wzh.glsc.product.web
 * @ClassName:@{NAME}
 * @Description:
 * @date:@{DATE}@{TIME}
 */
@Controller
public class ItemController {

    @Resource
    SkuInfoService skuInfoService;

    @GetMapping({"/{skuId}.html"})
    public String indexPage(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {
        //,Model model
        SkuItemVo skuItemVo=skuInfoService.item(skuId);
        model.addAttribute("item",skuItemVo);
        //springmvc会用视图解析器进行拼串
        //mvc会自动加上classpath:"/templates/"的前缀 +返回值 + '.htl' 的后缀
        return "item";
    }
}
